import { View } from "../../../../mvc/core/View";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { SSuitLockTip } from "../../../../../Message/Game/SSuitLockTip";
import { SuitConfig } from "../../../resource/SuitConfig";
import { ColorConfig } from "../../../resource/ColorConfig";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class SuitLockTipView
    
    export  class SuitLockTipView extends View
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._tipTxt = ObjCreate.createTextField("", 0, 0, 220, 20, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._linkTxt = ObjCreate.createTextField("", 130, 55, 220, 20, this);
            this._linkTxt.htmlText = Language.getString(36108);
            this._linkTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._linkTxt.addEventListener(flash.events.TextEvent.LINK, this.onLinkClickHandler);
            return;
        }

        public udpateBySuitLockTip(arg1: SSuitLockTip): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                this._suitName = SuitConfig.instance.getSuitNameByCode(arg1.suitCode);
                loc2 = ColorConfig.instance.getItemColorString(int(arg1.suitCode.toString().substr(2, 3)));
                if (arg1.canLock) 
                {
                    this._tipTxt.htmlText = Language.getStringByParam(36104, loc2, this._suitName);
                    this._linkTxt.visible = true;
                }
                else 
                {
                    if (arg1.isAtuo) 
                    {
                        loc1 = Language.getString(36105);
                    }
                    else 
                    {
                        loc1 = Language.getString(36106);
                    }
                    this._tipTxt.htmlText = Language.getStringByParam(36107, loc2, this._suitName, loc1);
                    this._linkTxt.visible = false;
                }
            }
            return;
        }

        /* internal  */onLinkClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerSuitLockOpen));
            Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipWindowHide));
            return;
        }

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_linkTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_suitName: string;
    }
